    <div class="main-content">
    	<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
				$(document).ready(function () {
					_init_department('company_id','department_id','<?php echo set_value('company_id');?>','<?php echo set_value('department_id');?>','<?php echo base_url();?>');
				 });
			</script>
	
			<!-- .breadcrumb -->
		</div>
		
        <!-- Main content -->
    <div class="page-content">
        <div class="page-header">
			<h1>用户创建</h1>
		</div>
        <div class="row">
			<div class="col-xs-12">
			<?php if (validation_errors()!=''){?>
	           <div id="info_msg" class="alert alert-danger"><?php echo validation_errors();?></div>
	        <?php }?>
	            <!-- general form elements disabled -->
	                <form id="usrform" role="form" action="<?php echo base_url().'admin/systems/add_user';?>" method="post">
	                	<input type="hidden" name="user_id" value="0">
	                	<div class="box-body" style="display: inline-block;width: 100%">
	                        <div class="form-group col-xs-6">
	                            <label>用户名</label>
	                            <input name="login_name" type="text" class="form-control" placeholder="输入 ..." value="<?php echo set_value("login_name")?>" check-type="required">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>密码</label>
	                            <input name="password" type="password" class="form-control" placeholder="输入 ..." value="<?php echo set_value("password")?>" check-type="required">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>姓名</label>
	                            <input name="user_name" type="text"  class="form-control" placeholder="输入 ..." value="<?php echo set_value("user_name")?>" check-type="required">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>联系电话</label>
	                            <input name="user_phone" type="text"  class="form-control" placeholder="输入 ..." value="<?php echo set_value("user_phone")?>"  check-type="required">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>所属公司</label>
	                            <select name="company_id" id="company_id" class="form-control" check-type="required">
	                            	<option value="">请选择所属公司</option>
	                            </select>
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>所属部门</label>
	                            <select id="department_id" name="department_id" class="form-control">
	                            	<option value="0">请选择所属部门</option>
	                            </select>
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>用户角色</label>
	                            <select name="role_id" class="form-control" check-type="required">
	                            	<option value="">请选择用户角色</option>
	                            	<?php if (isset($role)&&count($role)>0){
		                            	foreach ($role as $val){?>
		                            <option value="<?php echo $val->id?>" <?php if ($val->id==set_value("role_id")){?>selected<?php }?>><?php echo $val->role_name?></option>
		                            <?php }
		                            	}?>
	                            </select>
	                        </div>
                            <!--
	                        <div class="form-group col-xs-6">
	                            <label>加油站管理身份</label>
	                            <select name="gasstation_id" id="gasstation_id" disabled="disabled" class="form-control" readonly="readonly">
	                            	<option value="0">请选择加油站</option>
	                                <?php if (isset($gasstation)&&count($gasstation)>0){
	                                    foreach ($gasstation as $val){?>
		                            <option value="<?php echo $val->id?>" <?php if (isset($user_info->gasstation_id)&&$val->id==$user_info->gasstation_id){?>selected<?php }?>><?php echo $val->gasstation_name?></option>
		                            <?php }
		                            	}?>
	                            </select>
	                        </div>-->
	                        
	                	</div><!-- /.box-body -->
	                	<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button id="btnSubmit" class="btn btn-info" type="submit">
								<i class="icon-ok bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp; &nbsp;
							<a class="btn" href="<?php echo base_url()."admin/systems/user"?>">
								<i class="icon-undo bigger-110"></i>
								返回
							</a>
						</div>
					</div>
	                </form>
	        </div>
		</div>
    </div>
</div>
	<script type="text/javascript">
	$("#usrform").validation();
	//保存
	$("#btnSubmit").on('click',function(event){
	  // 2.最后要调用 valid()方法。
	  if ($("#usrform").valid()==false){
	    return false;
	  }
	});
	function _init_department(company_id,department_id,select_company_id,select_department_id,base_url){
		$('#'+company_id).change(function(){
			department_option(company_id,department_id,select_department_id,base_url);
		});
		$.ajax( {
	        url:base_url+'admin/systems/company',
	        data:{},
	        type:'post',
	        cache:false,
	        dataType:'json',    
	        success:function(data) {
	        	var company = document.getElementById(company_id);
	        	company.options.length = 1;
	        	for(var i=0; i<data.company.length; i++)
				{
	        		var len = company.length;
	        		company.options[len] = new Option(data.company[i].name, data.company[i].id);
					if (company.options[len].value == select_company_id)
					{
						company.options[len].selected = true;
					}
				}
	        	department_option(company_id,department_id,select_department_id,base_url);
	        },
	        error : function() {       
	            alert("error");
	        }
		});
	}
	function department_option(company_id,department_id,select_department_id,base_url){
		$.ajax( {
	        url:base_url+'admin/systems/show_department',
	        data:{company_id:$('#'+company_id).val()},
	        type:'post',
	        cache:false,
	        dataType:'json',    
	        success:function(data) {
	        	var department = document.getElementById(department_id);
	        	department.options.length = 1;
	        	for(var i=0; i<data.department.length; i++)
				{
	        		var len = department.length;
	        		department.options[len] = new Option(data.department[i].text, data.department[i].id);
					if (department.options[len].value == select_department_id)
					{
						department.options[len].selected = true;
					}
				}
	        	
	        },
	        error : function() {       
	            alert("error");
	        }
		});
	}
	</script>